package com.imooc.utils;

import com.imooc.vo.ResultVO;

/**
 * FileName: ResultVOUtil.java
 * Description: 构建ResultVO工具类
 *
 * @author HuangRI(874668739 @ qq.com)
 * @version 1.0
 * @date 2020/12/17
 */
public final class ResultVOUtil {

    private ResultVOUtil() {}

    public static ResultVO build(Integer code, String msg) {
        return new ResultVO(code, msg);
    }

    public static <T> ResultVO build(Integer code, String msg, T data) {
        return new ResultVO(code, msg, data);
    }

    /**
     * 成功
     * @return
     */
    public static ResultVO ok() {
        return build(0, "成功");
    }

    /**
     * 成功
     * @param data
     * @param <T>
     * @return
     */
    public static <T> ResultVO ok(T data) {
        return build(0, "成功", data);
    }

    /**
     * 失败
     * @param code
     * @param msg
     * @return
     */
    public static ResultVO error(Integer code, String msg) {
        return build(code, msg);
    }
}
